package com.jmb.waimao.example;

import com.jmb.waimao.client.MCPEmailClient;

import java.util.HashMap;
import java.util.Map;

/**
 * Example of how to use the MCP Email Client
 */
public class MCPEmailExample {
    
    public static void main(String[] args) {
        // Create a new MCP Email Client
        MCPEmailClient client = new MCPEmailClient("http://localhost:8080/");
        
        // Get the status of the email service
        Map<String, Object> status = client.getStatus();
        System.out.println("Email Service Status: " + status);
        
        // Configure the email service (if needed)
        Map<String, Object> config = new HashMap<>();
        config.put("host", "smtp.example.com");
        config.put("port", 587);
        config.put("username", "user@example.com");
        config.put("password", "password");
        config.put("fromEmail", "sender@example.com");
        
        Map<String, Object> properties = new HashMap<>();
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.starttls.enable", "true");
        config.put("properties", properties);
        
        Map<String, Object> configResponse = client.configure(config);
        System.out.println("Configuration Response: " + configResponse);
        
        // Send a simple email
        Map<String, Object> emailResponse = client.sendEmail(
                "recipient@example.com",
                "Test Email",
                "<h1>Hello World!</h1><p>This is a test email sent using the MCP Email Client.</p>"
        );
        System.out.println("Email Response: " + emailResponse);
        
        // Send a templated email
        Map<String, Object> variables = new HashMap<>();
        variables.put("name", "John Doe");
        variables.put("company", "Example Inc.");
        variables.put("product", "MCP Email Service");
        
        Map<String, Object> templateResponse = client.sendTemplatedEmail(
                "recipient@example.com",
                "Welcome to {{company}}",
                1L, // Template ID
                variables
        );
        System.out.println("Template Response: " + templateResponse);
    }
}
